package com.szy.assembly;

public class AssemblerError {
    private int lineNumber;
    private AssemblerErrorEnum error;
    private String originCode="";



    public AssemblerError(int lineNumber,AssemblerErrorEnum error,String origin){
        this.lineNumber=lineNumber;
        this.error=error;
        this.originCode=origin;
    }

    @Override
    public String toString() {
        String describe="";
        switch (error){
            case NO_ERROR:
                describe="There are no errors here, if you see this, it must be that szy writes a bug.";
                break;
            case WRONG_LABEL_FORMAT:
                describe="Wrong label format.";
                break;
            case MANY_COLON:
                describe="Too many colons.";
                break;
            case WRONG_OPCODE:
                describe="Could not find this opcode.";
                break;
            case MISMATCH_OPERAND_NUM:
                describe="The number of operands does not match.";
                break;
            case WRONG_OPERAND_FORMAT:
                describe="Wrong operand format";
                break;
            case REPEAT_LABEL:
                describe="This label has already appeared.";
                break;
            case UNKNOW_LABEL:
                describe="Undefined label.";
                break;
        }
        return "Assembler error(line "+lineNumber+"):\n"+describe+"\n"+lineNumber+":"+originCode;
    }
}
